home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / NOTEIMPL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-30  |  5.4 KB  |  211 lines

  1. unit NoteImpl;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelLib, ExtCtrls;
  8.  
  9. type
  10.   TNotebookX = class(TActiveXControl, INotebookX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TNotebook;
  14.     FEvents: INotebookXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  17.     procedure PageChangedEvent(Sender: TObject);
  18.   protected
  19.     { Protected declarations }
  20.     procedure InitializeControl; override;
  21.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     function Get_ActivePage: WideString; safecall;
  24.     function Get_Color: TColor; safecall;
  25.     function Get_Ctl3D: WordBool; safecall;
  26.     function Get_Cursor: Smallint; safecall;
  27.     function Get_DragCursor: Smallint; safecall;
  28.     function Get_Enabled: WordBool; safecall;
  29.     function Get_Font: Font; safecall;
  30.     function Get_PageIndex: Integer; safecall;
  31.     function Get_Pages: IStrings; safecall;
  32.     function Get_ParentColor: WordBool; safecall;
  33.     function Get_Visible: WordBool; safecall;
  34.     procedure AboutBox; safecall;
  35.     procedure Set_ActivePage(const Value: WideString); safecall;
  36.     procedure Set_Color(Value: TColor); safecall;
  37.     procedure Set_Ctl3D(Value: WordBool); safecall;
  38.     procedure Set_Cursor(Value: Smallint); safecall;
  39.     procedure Set_DragCursor(Value: Smallint); safecall;
  40.     procedure Set_Enabled(Value: WordBool); safecall;
  41.     procedure Set_Font(const Value: Font); safecall;
  42.     procedure Set_PageIndex(Value: Integer); safecall;
  43.     procedure Set_Pages(const Value: IStrings); safecall;
  44.     procedure Set_ParentColor(Value: WordBool); safecall;
  45.     procedure Set_Visible(Value: WordBool); safecall;
  46.   end;
  47.  
  48. implementation
  49. uses NoteBPg;
  50. { TNotebookX }
  51.  
  52. procedure TNotebookX.InitializeControl;
  53. begin
  54.   FDelphiControl := Control as TNotebook;
  55.   FDelphiControl.OnClick := ClickEvent;
  56.   FDelphiControl.OnDblClick := DblClickEvent;
  57.   FDelphiControl.OnPageChanged := PageChangedEvent;
  58. end;
  59.  
  60. procedure TNotebookX.EventSinkChanged(const EventSink: IUnknown);
  61. begin
  62.   FEvents := EventSink as INotebookXEvents;
  63. end;
  64.  
  65. procedure TNotebookX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  66. begin
  67.   { Define property pages here.  Property pages are defined by calling
  68.     DefinePropertyPage with the class id of the page.  For example,
  69.       DefinePropertyPage(Class_NotebookXPage); }
  70. end;
  71.  
  72. function TNotebookX.Get_ActivePage: WideString;
  73. begin
  74.   Result := WideString(FDelphiControl.ActivePage);
  75. end;
  76.  
  77. function TNotebookX.Get_Color: TColor;
  78. begin
  79.   Result := FDelphiControl.Color;
  80. end;
  81.  
  82. function TNotebookX.Get_Ctl3D: WordBool;
  83. begin
  84.   Result := FDelphiControl.Ctl3D;
  85. end;
  86.  
  87. function TNotebookX.Get_Cursor: Smallint;
  88. begin
  89.   Result := Smallint(FDelphiControl.Cursor);
  90. end;
  91.  
  92. function TNotebookX.Get_DragCursor: Smallint;
  93. begin
  94.   Result := Smallint(FDelphiControl.DragCursor);
  95. end;
  96.  
  97. function TNotebookX.Get_Enabled: WordBool;
  98. begin
  99.   Result := FDelphiControl.Enabled;
  100. end;
  101.  
  102. function TNotebookX.Get_Font: Font;
  103. begin
  104.   GetOleFont(FDelphiControl.Font, Result);
  105. end;
  106.  
  107. function TNotebookX.Get_PageIndex: Integer;
  108. begin
  109.   Result := FDelphiControl.PageIndex;
  110. end;
  111.  
  112. function TNotebookX.Get_Pages: IStrings;
  113. begin
  114.   GetOleStrings(FDelphiControl.Pages, Result);
  115. end;
  116.  
  117. function TNotebookX.Get_ParentColor: WordBool;
  118. begin
  119.   Result := FDelphiControl.ParentColor;
  120. end;
  121.  
  122. function TNotebookX.Get_Visible: WordBool;
  123. begin
  124.   Result := FDelphiControl.Visible;
  125. end;
  126.  
  127. procedure TNotebookX.AboutBox;
  128. begin
  129.   ShowNotebookXAbout;
  130. end;
  131.  
  132. procedure TNotebookX.Set_ActivePage(const Value: WideString);
  133. begin
  134.   FDelphiControl.ActivePage := String(Value);
  135. end;
  136.  
  137. procedure TNotebookX.Set_Color(Value: TColor);
  138. begin
  139.   FDelphiControl.Color := Value;
  140. end;
  141.  
  142. procedure TNotebookX.Set_Ctl3D(Value: WordBool);
  143. begin
  144.   FDelphiControl.Ctl3D := Value;
  145. end;
  146.  
  147. procedure TNotebookX.Set_Cursor(Value: Smallint);
  148. begin
  149.   FDelphiControl.Cursor := TCursor(Value);
  150. end;
  151.  
  152. procedure TNotebookX.Set_DragCursor(Value: Smallint);
  153. begin
  154.   FDelphiControl.DragCursor := TCursor(Value);
  155. end;
  156.  
  157. procedure TNotebookX.Set_Enabled(Value: WordBool);
  158. begin
  159.   FDelphiControl.Enabled := Value;
  160. end;
  161.  
  162. procedure TNotebookX.Set_Font(const Value: Font);
  163. begin
  164.   SetOleFont(FDelphiControl.Font, Value);
  165. end;
  166.  
  167. procedure TNotebookX.Set_PageIndex(Value: Integer);
  168. begin
  169.   FDelphiControl.PageIndex := Value;
  170. end;
  171.  
  172. procedure TNotebookX.Set_Pages(const Value: IStrings);
  173. begin
  174.   SetOleStrings(FDelphiControl.Pages, Value);
  175. end;
  176.  
  177. procedure TNotebookX.Set_ParentColor(Value: WordBool);
  178. begin
  179.   FDelphiControl.ParentColor := Value;
  180. end;
  181.  
  182. procedure TNotebookX.Set_Visible(Value: WordBool);
  183. begin
  184.   FDelphiControl.Visible := Value;
  185. end;
  186.  
  187. procedure TNotebookX.ClickEvent(Sender: TObject);
  188. begin
  189.   if FEvents <> nil then FEvents.OnClick;
  190. end;
  191.  
  192. procedure TNotebookX.DblClickEvent(Sender: TObject);
  193. begin
  194.   if FEvents <> nil then FEvents.OnDblClick;
  195. end;
  196.  
  197. procedure TNotebookX.PageChangedEvent(Sender: TObject);
  198. begin
  199.   if FEvents <> nil then FEvents.OnPageChanged;
  200. end;
  201.  
  202. initialization
  203.   TActiveXControlFactory.Create(
  204.     ComServer,
  205.     TNotebookX,
  206.     TNotebook,
  207.     Class_NotebookX,
  208.     14,
  209.     '{5A56599F-7975-11D0-BE02-00A024D1875C}');
  210. end.
  211.